package com.mumulx.check.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;


/**
 * 用户的基本信息
 * @author mumulx
 * @creed: mumulx编写
 * @email: 2606964863@qq.com
 * @date 2020/11/5 23:12
 *
 */
@Data
@ApiModel(value = "com.mumulx.check.model.UserInfo",description = "用户个人信息")
public class UserInfo implements UserDetails {

    @ApiModelProperty(value = "用户id")
    private Integer userId;

    @NotBlank(message = "昵称不能为空")
    @ApiModelProperty(value = "昵称")
    private String userName;

    @ApiModelProperty(value = "联系电话")
    @NotBlank(message = "联系电话不能为空")
    private String userTel;

    @ApiModelProperty(value = "密码")
    @NotBlank(message = "密码不能为空")
    private String userPwd;

    @ApiModelProperty(value = "电子邮箱")
    @NotBlank(message = "电子邮箱不能为空")
    private String userEmail;

    @ApiModelProperty(value = "出生日期")
    @NotBlank(message = "出生日期不能为空")
    private String userBirthday;

    @ApiModelProperty(value = "性别")
    @NotBlank(message = "性别不能为空")
    private String userSex;

    @ApiModelProperty(value = "联系地址")
    @NotBlank(message = "联系地址不能为空")
    private String userAddress;

    /**用于用户权限记录**/

    @ApiModelProperty(value = "账号是否可用")
    private boolean userEnabled;  //账号是否可用

    private Collection<? extends GrantedAuthority> authorities;  //用户的权限集合


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return userPwd;
    }

    @Override
    public String getUsername() {
        return userTel;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }


    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return userEnabled;
    }


}
